# -*- coding: utf-8 -*-
"""
author:码同学 极光
date:2024/10/19
desc: 
sample: 
"""
import os

import allure
import pytest
import requests
from allure_commons.types import LinkType

host = 'http://121.11.97.201:9088/pinter/com/'



@pytest.mark.parametrize("id",['1','2','3','5'])
def test_getSku(id):
   print('----------路径-----------------',os.getcwd())
   response = requests.get(url=f'{host}getSku?id={id}')
   print(response)
   assert response.status_code == 200
   res_dict = response.json()
   # json字符串 -》 字典
   print(type(res_dict))
   assert res_dict['code'] == '0'

@pytest.mark.parametrize("username,pwd",[('admin','123456'),('test1','123')])
def test2(username,pwd):
     print(username,pwd)


@pytest.mark.parametrize("username,pwd",[['admin', '123456'], ['test1','123456']])
def test3(username,pwd):
   print(username)


test_data = [
    {
        'case': '登入成功',
        'usr': 'admin',  # 正常登入
        'psw': '123456'
    },
    {
        'case': '账号不存在',
        'usr': 'admin1',  # 账号不存在
        'psw': '123456'
    },
    {
        'case': '密码错误',
        'usr': 'admin',  # 密码错误
        'psw': '12345'
    },
    {
        'case': '账号或密码为空',
        'usr': '',  # 账号或密码为空
        'psw': ''
    },
]

@allure.parent_suite('我是parent_suite')
@allure.suite('我是suite')
@allure.sub_suite('我是sub_suite')
@allure.feature('测试参数化')
@allure.id('我是id')
@allure.title('我是title')
@allure.link('https://www.baidu.com/', LinkType.LINK, '我是link')
@allure.label('我是label')
@allure.issue('https://www.baidu.com/', '我是issue')
@allure.description('我是description')
@allure.severity('我是severity')
@pytest.mark.parametrize('param', test_data,ids=[item.get('case') for item in test_data])
def test4(param):
    usr = param.get('usr')
    psw = param.get('psw')
    print(f'usr: {usr} , psw: {psw}')
